package com.fingard.dsp.bank.reqrespobj.single.detail;

import com.fingard.FGBiz;
import com.fingard.constant.Format;
import com.fingard.dsp.bank.directbank.specialDeal.BankAreaHelper;
import com.fingard.text.StringHelper;
import com.fingard.xml.XElement;

import java.text.ParseException;
import java.util.Date;

//单笔合批状态查询请求明细对象
public class ReqQrySglBatPayDetail {
    /*
    <ReqSeqID></ReqSeqID>
    <BgnDate></BgnDate>
    <PayAct></PayAct>
    <PayArea></PayArea>
    <PayCur></PayCur>
    <InnerPay></InnerPay>
    <IsPrivate></IsPrivate>
    * */

    public String reqSeqID;
    public String bgnDate;
    public String payAct;
    public String payName;
    public String payArea;
    public String payCur;
    public String innerPay;
    public String isPrivate;
    public String payAmount;
    public String payBankCode;
    public String recBankCode;
    public String payState;
    public String officePurpose;
    public String circMchNo;
    public String certType;
    public String certNum;
    public String authCode;
    public String insuPolicyNum;
    public String memo;
    public String orderNo;

    public ReqQrySglBatPayDetail(XElement p_xelement,String p_bankCode) throws Exception {
        reqSeqID = p_xelement.getSingleText("ReqSeqID");
        orderNo = p_xelement.getSingleTextNotNull("OrderNumber");
        bgnDate = p_xelement.getSingleText("BgnDate");
        payAct = p_xelement.getSingleText("PayAct");
        payName = p_xelement.getSingleText("PayName");
        payArea = p_xelement.getSingleText("PayArea");
        if (FGBiz.dspCenter.convertBankArea) {
            BankAreaHelper bankAreaHelper=new BankAreaHelper(p_bankCode,payArea,"");
            bankAreaHelper.toBank();
            payArea=bankAreaHelper.bankAreaCode;
        }
        payCur = p_xelement.getSingleText("PayCur");
        innerPay = p_xelement.getSingleText("InnerPay");
        isPrivate = p_xelement.getSingleText("IsPrivate");
        payAmount = p_xelement.getSingleText("PayAmount");

        payBankCode = p_xelement.getSingleTextNotNull("PayBankCode");
		recBankCode = p_xelement.getSingleTextNotNull("RecBankCode");

		payState = p_xelement.getSingleText("PayState");
		if(StringHelper.isNullOrEmpty(payState)){
			payState = "5";
		}
        officePurpose = p_xelement.getSingleText("OfficePurpose");
        circMchNo = p_xelement.getSingleText("CircMchNo");
        certType = p_xelement.getSingleText("CertType");
        certNum = p_xelement.getSingleText("CertNum");
        authCode = p_xelement.getSingleText("AuthCode");
        insuPolicyNum = p_xelement.getSingleText("InsuPolicyNum");
        memo = p_xelement.getSingleText("Memo");
    }

    public Date getBgnDateTime() throws ParseException {
        return Format.DateTimeFormat.parse(bgnDate);
    }
}
